import isPromise from 'is-promise'

export default function promise({ dispatch }: { dispatch: (action: unknown) => unknown }) {
    return (next: Function) => (action: IAction) => {
        return isPromise(action) ? action.then(dispatch) : next(action)
    }
}